﻿using NUnitForVSTS;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace NUnitForVSTS.NUnitTest.UT
{
    
    
    /// <summary>
    ///This is a test class for HashUtilityTest and is intended
    ///to contain all HashUtilityTest Unit Tests
    ///</summary>
    [TestClass()]
    public class HashUtilityTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GuidFromString to see if empty strins are handled correctly
        ///</summary>
        [TestMethod()]
        public void HashUtility_GuidFromEmptyStringTest()
        {
            string data = string.Empty;
            Guid expected = new Guid("eea339da-6b5e-0d4b-3255-bfef95601890");
            Guid actual;
            actual = HashUtility.GuidFromString(data);
            Assert.AreEqual(expected, actual, "Empty string should result in the id:eea339da-6b5e-0d4b-3255-bfef95601890");
        }

        /// <summary>
        ///A test for GuidFromString to see if the guids are created correctly
        /// Generates Hash Id's for the Unit Tests.
        /// Apparently these are not just guids, these are SHA1 hashes of the test cases.
        /// http://blogs.msdn.com/dhopton/archive/2008/06/12/helpful-internals-of-trx-and-vsmdi-files.aspx
        ///</summary>
        [TestMethod()]
        public void HashUtility_GuidFromStringTest()
        {
            string data = "Company.Product.TestClass.TestMethod";
            Guid expected = new Guid("be816775-d9e3-dc08-5a19-dae308fd4991");
            Guid actual;
            actual = HashUtility.GuidFromString(data);
            Assert.AreEqual(expected, actual, "Same Methodname should result in Same Guid");
        }

        /// <summary>
        /// Hashes the utility_ null string test.
        /// </summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void HashUtility_NullStringTest()
        {
            HashUtility.GuidFromString(null);
        }
    }
}
